home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / mach / sun4c.md / machConst.h < prev    next >
C/C++ Source or Header  |  1991-08-02  |  19KB  |  529 lines

  1. /*
  2.  * machConst.h --
  3.  *
  4.  *     Machine dependent constants.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * $Header: /sprite/src/kernel/mach/sun4.md/RCS/machConst.h,v 9.9 91/08/02 18:42:23 mgbaker Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _MACHCONST
  14. #define _MACHCONST
  15.  
  16. #ifdef KERNEL
  17. #include "sprite.h"
  18. #include "vmSunConst.h"
  19. #include "sysSysCall.h"
  20. #include "sys.h"
  21. #include "status.h"
  22. #else
  23. #include <kernel/vmSunConst.h>
  24. #include <kernel/sysSysCall.h>
  25. #include <kernel/sys.h>
  26. #include "status.h"
  27. #endif
  28.  
  29.  
  30. /*
  31.  * Return codes from some trap routines.
  32.  *
  33.  *    MACH_OK        Successfully handled.
  34.  *    MACH_KERN_ERROR    Debugger must be called.
  35.  *    MACH_USER_ERROR    User process error (bad stack, etc).  Kill user process.
  36.  *    MACH_SIG_RETURN    Returning from signal handler.
  37.  *
  38.  */
  39. #define    MACH_OK        0
  40. #define    MACH_KERN_ERROR    1
  41. #define    MACH_USER_ERROR    2
  42. #define    MACH_SIG_RETURN    3
  43.  
  44. /*
  45.  * Here are the different types of exceptions, represented by the contents
  46.  * of the trap type bits in the trap base register..  These are listed in order
  47.  * of highest priority to lowest. All the MACH_TRAP_INSTR's are of the same
  48.  * priority.
  49.  *
  50.  * Trap Name            Trap Type Field
  51.  */
  52. #define    MACH_RESET        0x000
  53. #define    MACH_INSTR_ACCESS    0x010
  54. #define    MACH_ILLEGAL_INSTR    0x020
  55. #define    MACH_PRIV_INSTR        0x030
  56. #define    MACH_FP_DISABLED    0x040
  57. #define    MACH_CP_DISABLED    0x240        /* 36 */
  58. #define    MACH_WINDOW_OVERFLOW    0x050
  59. #define    MACH_WINDOW_UNDERFLOW    0x060
  60. #define    MACH_MEM_ADDR_ALIGN    0x070
  61. #define    MACH_FP_EXCEP        0x080
  62. #define    MACH_CP_EXCEP        0x280        /* 40 */
  63. #define    MACH_DATA_ACCESS    0x090
  64. #define    MACH_TAG_OVERFLOW    0x0a0
  65. #define    MACH_TRAP_INSTR_FIRST    0x800        /* 128 */
  66. #define    MACH_TRAP_INSTR_1    0x810        /* 129 */
  67. #define    MACH_TRAP_INSTR_2    0x820        /* 130 */
  68. #define    MACH_TRAP_INSTR_3    0x830        /* 131 */
  69. #define    MACH_TRAP_INSTR_4    0x840        /* 132 */
  70. #define    MACH_TRAP_INSTR_5    0x850        /* 133 */
  71. #define    MACH_TRAP_INSTR_LAST    0xff0
  72.  
  73. #define    MACH_LEVEL0_INT        0x100        /* 16 */
  74. #define    MACH_LEVEL1_INT        0x110        /* 17 */
  75. #define    MACH_LEVEL2_INT        0x120
  76. #define    MACH_LEVEL3_INT        0x130
  77. #define    MACH_LEVEL4_INT        0x140
  78. #define    MACH_LEVEL5_INT        0x150
  79. #define    MACH_LEVEL6_INT        0x160
  80. #define    MACH_LEVEL7_INT        0x170
  81. #define    MACH_LEVEL8_INT        0x180
  82. #define    MACH_LEVEL9_INT        0x190
  83. #define    MACH_LEVEL10_INT    0x1a0
  84. #define    MACH_LEVEL11_INT    0x1b0
  85. #define    MACH_LEVEL12_INT    0x1c0
  86. #define    MACH_LEVEL13_INT    0x1d0
  87. #define    MACH_LEVEL14_INT    0x1e0
  88. #define    MACH_LEVEL15_INT    0x1f0
  89.  
  90. #define    MACH_TRAP_UNIX_SYSCALL    MACH_TRAP_INSTR_FIRST
  91. #define    MACH_TRAP_DEBUGGER    MACH_TRAP_INSTR_1
  92. #define    MACH_TRAP_SYSCALL    MACH_TRAP_INSTR_3
  93. #define    MACH_TRAP_SIG_RETURN    MACH_TRAP_INSTR_4
  94. #define    MACH_TRAP_FLUSH_WINDOWS    MACH_TRAP_INSTR_5
  95.  
  96. /*
  97.  * Our trap type is the 2 second to the last hex digits of the tbr register.
  98.  * So "trap type 3" shows up in the last 3 digits of the tbr as 0x030, and
  99.  * trap type 15 shows up as 0x1f0.  The trap types for the software trap
  100.  * instructions start at trap type 128 (0x800 in the tbr).  To get the arguments
  101.  * to a software trap instruction, we take the trap type, subtract off 0x800,
  102.  * and then shift it right by 4 bits to chop off the lowest hex digit.
  103.  * Thus the trap instruction "ta 0" has a trap type of 128 == 0x80 (== 0x800 in
  104.  * the tbr), and ta 1 has a trap type of 129 showing up as 0x810 in the tbr.
  105.  */
  106. /* trap instruction number is trap type - trap type 128 = 0x80 (== -0x800) */
  107. #define    MACH_CALL_DBG_TRAP    ((MACH_TRAP_DEBUGGER - 0x800) >>4)
  108. #define    MACH_BRKPT_TRAP        ((MACH_TRAP_INSTR_2 - 0x800) >>4)
  109. #define    MACH_SYSCALL_TRAP    ((MACH_TRAP_SYSCALL - 0x800) >> 4)
  110. #define    MACH_RET_FROM_SIG_TRAP    ((MACH_TRAP_SIG_RETURN - 0x800) >> 4)
  111. #define    MACH_FLUSH_WINDOWS_TRAP    ((MACH_TRAP_FLUSH_WINDOWS - 0x800) >> 4)
  112.  
  113. /*
  114.  * Mask for extracting the trap type from the tbr.
  115.  */
  116. #define    MACH_TRAP_TYPE_MASK    0xFF0
  117. /*
  118.  * Mask for extracting the trap base address from the tbr.
  119.  */
  120. #define MACH_TRAP_ADDR_MASK    0xFFFFF000
  121.  
  122. /*
  123.  *  Masks for 16 interrupt priority levels:
  124.  *   lowest = 0,   highest = 15.
  125.  */
  126. #define    MACH_SR_PRIO_0        0x0000
  127. #define    MACH_SR_PRIO_1        0x0100
  128. #define    MACH_SR_PRIO_2        0x0200
  129. #define    MACH_SR_PRIO_3        0x0300
  130. #define    MACH_SR_PRIO_4        0x0400
  131. #define    MACH_SR_PRIO_5        0x0500
  132. #define    MACH_SR_PRIO_6        0x0600
  133. #define    MACH_SR_PRIO_7        0x0700
  134. #define    MACH_SR_PRIO_8        0x0700
  135. #define    MACH_SR_PRIO_9        0x0700
  136. #define    MACH_SR_PRIO_10        0x0700
  137. #define    MACH_SR_PRIO_11        0x0700
  138. #define    MACH_SR_PRIO_12        0x0700
  139. #define    MACH_SR_PRIO_13        0x0700
  140. #define    MACH_SR_PRIO_14        0x0700
  141. #define    MACH_SR_PRIO_15        0x0700
  142.  
  143. /*
  144.  *  State priorities in the processor state register (psr):
  145.  *
  146.  *    MACH_SR_HIGHPRIO    Supervisor mode + interrupts disabled, traps on
  147.  *    MACH_SR_LOWPRIO        Supervisor mode + interrupts enabled, traps on
  148.  *    MACH_SR_USERPRIO    User mode, traps on
  149.  *
  150.  *    For the sun4, these are macros in machAsmDefs.h.  I can't just move
  151.  *    values into the psr the way the sun3 and sun2 do, since that would
  152.  *    change the window we're in, etc.
  153.  */
  154.  
  155. /*
  156.  * Constants to access bits in the psr register.
  157.  */
  158. #define    MACH_ENABLE_INTR        0xFFFFF0FF    /* and with psr */
  159. #define    MACH_DISABLE_INTR        (~MACH_ENABLE_INTR)    /* or w/ psr */
  160. #define MACH_ENABLE_FPP            0x1000
  161. #define    MACH_CWP_BITS            0x1f    /* cwp bits in psr */
  162. #define    MACH_ENABLE_TRAP_BIT        0x20    /* or with %psr */
  163. #define    MACH_DISABLE_TRAP_BIT        0xFFFFFFDF    /* and with %psr */
  164. #define    MACH_SUPER_BIT            0x80
  165. #define    MACH_PS_BIT            0x40    /* and with psr - prev. state */
  166. #define    MACH_FIRST_USER_PSR        0x080    /* traps off, interrupts on,
  167.                          * previous mode not supervisor,
  168.                          * current mode supervisor. */
  169. #define    MACH_PSR_SIG_RESTORE        0xF00000 /* Bits to restore from sig */ 
  170. #define    MACH_NO_INTR_USER_PSR        0xF80
  171. #define MACH_CARRY_BIT            0x00100000
  172. #define MACH_CARRY_BITMASK        (~MACH_CARRY_BIT)
  173. /*
  174.  * psr value for interrupts disabled, traps enabled and window 0.
  175.  * Both supervisor and previous supervisor mode bits are set.
  176.  */
  177. #define    MACH_HIGH_PRIO_PSR        0x00000FE0
  178.  
  179. /*
  180.  * FPU fsr bits.
  181.  */
  182.  
  183. #define    MACH_FSR_QUEUE_NOT_EMPTY     0x2000
  184. #define    MACH_FSR_TRAP_TYPE_MASK        0x1c000
  185. #define    MACH_FSR_NO_TRAP        0x00000
  186. #define    MACH_FSR_IEEE_TRAP        0x04000
  187. #define    MACH_FSR_UNFINISH_TRAP        0x08000
  188. #define    MACH_FSR_UNIMPLEMENT_TRAP    0x0c000
  189. #define    MACH_FSR_SEQ_ERRROR_TRAP    0x10000
  190.  
  191. /*
  192.  * Bits to enable interrupts in interrupt register.
  193.  */
  194. #define    MACH_ENABLE_ALL_INTERRUPTS    0x1
  195. #define    MACH_ENABLE_LEVEL1_INTR        0x2
  196. #define    MACH_ENABLE_LEVEL4_INTR        0x4
  197. #define    MACH_ENABLE_LEVEL6_INTR        0x8
  198. #define    MACH_ENABLE_LEVEL8_INTR        0x10
  199. #define    MACH_ENABLE_LEVEL10_INTR    0x20
  200. #define    MACH_ENABLE_LEVEL14_INTR    0x80
  201. /*
  202.  * Bit to enable in interrupt register for timer.
  203.  */
  204. #ifdef sun4c
  205. #define    MACH_ENABLE_COUNTER0_INTR_LEVEL    MACH_ENABLE_LEVEL10_INTR
  206. #define    MACH_ENABLE_COUNTER1_INTR_LEVEL    MACH_ENABLE_LEVEL14_INTR
  207. #else
  208. #define    MACH_ENABLE_TIMER_INTR_LEVEL    MACH_ENABLE_LEVEL10_INTR
  209. #endif
  210.  
  211. /*
  212.  * Bits to access bus error register.
  213.  */
  214. #ifdef sun4c
  215. #define    MACH_SIZE_ERROR        0x02
  216. #define    MACH_SB_ERROR        0x10
  217. #define    MACH_TIMEOUT_ERROR    0x20
  218. #define    MACH_PROT_ERROR        0x40
  219. #define    MACH_INVALID_ERROR    0x80
  220. #else
  221. #define    MACH_SIZE_ERROR        0x02
  222. #define    MACH_VME_ERROR        0x10
  223. #define    MACH_TIMEOUT_ERROR    0x20
  224. #define    MACH_PROT_ERROR        0x40
  225. #define    MACH_INVALID_ERROR    0x80
  226. #endif
  227.  
  228. /*
  229.  * MACH_KERN_START    The address where the kernel image is loaded at.
  230.  * MACH_CODE_START    The address where the kernel code is loaded at.
  231.  * MACH_STACK_START The address of the base of the stack.  1st word is unusable.
  232.  * MACH_STACK_BOTTOM    The address of the bottom of the kernel stack for the
  233.  *            main process that is initially run.
  234.  * MACH_KERN_END    The address where the last kernel virtual address is
  235.  *            at.
  236.  * MACH_KERN_STACK_SIZE Number of bytes in a kernel stack.
  237.  * MACH_BARE_STACK_OFFSET    Offset of where a bare kernel stack starts.
  238.  *                It doesn't start at the very top because
  239.  *                the debugger requires a couple of integers
  240.  *                of padding on the top.
  241.  * MAGIC        A magic number which is pushed onto the stack before
  242.  *            a context switch.  Used to verify that the stack
  243.  *            doesn't get trashed.
  244.  * MACH_UNIX_ERRNO_OFFSET    Errno offset in Proc_ControlBlock
  245.  */
  246. #define    MACH_KERN_START        0xf6000000
  247. #define    MACH_STACK_START    (MACH_KERN_START + 0x6000)
  248. #define    MACH_CODE_START        (MACH_STACK_START + 0x20)
  249. #define    MACH_STACK_BOTTOM    MACH_KERN_START
  250. #define MACH_KERN_END        VMMACH_NET_MAP_START
  251. #define    MACH_KERN_STACK_SIZE    (MACH_STACK_START - MACH_STACK_BOTTOM)
  252. #define    MACH_BARE_STACK_OFFSET    (MACH_KERN_STACK_SIZE - 8)
  253. #define    MACH_UNIX_ERRNO_OFFSET    696    /* Offset checked in Mach_Init. */
  254.  
  255. /*
  256.  * Constants for the user's address space.
  257.  *
  258.  * MACH_FIRST_USER_ADDR        The lowest possible address in the user's VAS.
  259.  * MACH_LAST_USER_ADDR        The highest possible address in the user's VAS.
  260.  * MACH_LAST_USER_STACK_PAGE    The highest page in the user stack segment.
  261.  * MACH_MAX_USER_STACK_ADDR    The highest value that the user stack pointer
  262.  *                can have.  Note that the stack pointer must be
  263.  *                decremented before anything can be stored on
  264.  *                the stack.  Also note that on the sun4 we must
  265.  *                strip off the high couple of bits, since 0's
  266.  *                and 1's in them point to the same entry in the
  267.  *                segment table.
  268.  *                ACTUALLY: it turns out we can't just strip
  269.  *                those bits, since doing so may put us in the
  270.  *                invalid hole, since the kernel doesn't start
  271.  *                right at the bottom of the top part after the
  272.  *                hole.  I'll have to deal with the user stack
  273.  *                not being contiguous in some way, so it can
  274.  *                start beneath the kernel and continue across
  275.  *                the hole, but for now, I just shrink everything
  276.  *                so the user process stack must start at the
  277.  *                top address beneath the hole.  Yuckola.
  278.  *
  279.  */
  280. #define    MACH_FIRST_USER_ADDR        VMMACH_PAGE_SIZE
  281. #define    MACH_LAST_USER_ADDR        (MACH_MAX_USER_STACK_ADDR - 1)
  282. #define    MACH_LAST_USER_STACK_PAGE    ((MACH_MAX_USER_STACK_ADDR - 1) / VMMACH_PAGE_SIZE)
  283. #ifdef NOTDEF
  284. #define    MACH_MAX_USER_STACK_ADDR    (VMMACH_MAP_SEG_ADDR & VMMACH_ADDR_MASK)
  285. #else
  286. #define    MACH_MAX_USER_STACK_ADDR    (0x20000000 - VMMACH_USER_SHARED_PAGES*VMMACH_PAGE_SIZE)
  287. #endif /* NOTDEF */
  288.  
  289. /*
  290.  * The control space offset of the VME interrupt vector.
  291.  */
  292. #define    MACH_VME_INTR_VECTOR        0xE0000000
  293.  
  294. /*
  295.  * Instruction executed from stack to cause a return trap to the kernel from
  296.  * a signal handler.  This is "ta MACH_RET_FROM_SIG_TRAP" instruction.
  297.  */
  298. #define    MACH_SIG_TRAP_INSTR    0x91d02004
  299. /*
  300.  * Constants for getting to offsets in structures:  To make sure these
  301.  * constants are correct, there is code in machCode.c that will cause
  302.  * the kernel to die upon booting if the offsets aren't what's here.
  303.  * All sizes are in bytes.
  304.  */
  305. /*
  306.  * Byte offsets from beginning of a Mach_RegState structure to the fields
  307.  * for the various types of registers.
  308.  */
  309. #define    MACH_LOCALS_OFFSET    0
  310. #define    MACH_INS_OFFSET        (MACH_LOCALS_OFFSET + MACH_NUM_LOCALS * 4)
  311. #define    MACH_GLOBALS_OFFSET    (MACH_INS_OFFSET + (MACH_NUM_INS * 2) * 4 + \
  312.                  MACH_NUM_EXTRA_ARGS * 4)
  313. #define    MACH_FPU_FSR_OFFSET    (MACH_GLOBALS_OFFSET + (MACH_NUM_GLOBALS * 4))
  314. #define    MACH_FPU_QUEUE_COUNT    (MACH_FPU_FSR_OFFSET + 4)
  315. #define    MACH_FPU_REGS_OFFSET    (MACH_FPU_QUEUE_COUNT + 4)
  316. #define    MACH_FPU_QUEUE_OFFSET    (MACH_FPU_REGS_OFFSET + (MACH_NUM_FPS * 4))
  317.  
  318. #define    MACH_SIG_STUFF_SIZE    ((MACH_SAVED_STATE_FRAME + 8 + 4) + 20)
  319.                         /* skip over calleeInputs too */
  320. /*
  321.  * Byte offset from beginning of a Mach_State structure to various register
  322.  * fields, the savedSps field, the savedRegs field, the savedMask field, 
  323.  * the kernStackStart, and the FPU status field.
  324.  */
  325. #define    MACH_TRAP_REGS_OFFSET    0
  326. #define    MACH_SWITCH_REGS_OFFSET    (MACH_TRAP_REGS_OFFSET + 4)
  327. #define    MACH_SAVED_REGS_OFFSET    (MACH_SWITCH_REGS_OFFSET + 4)
  328. #define    MACH_SAVED_MASK_OFFSET    (MACH_SAVED_REGS_OFFSET + (MACH_NUM_WINDOWS *\
  329.                 MACH_NUM_WINDOW_REGS * 4))
  330. #define    MACH_SAVED_SPS_OFFSET    (MACH_SAVED_MASK_OFFSET + 4)
  331. #define    MACH_KSP_OFFSET        (MACH_SAVED_SPS_OFFSET + (MACH_NUM_WINDOWS * 4))
  332. #define    MACH_FPU_STATUS_OFFSET  (MACH_KSP_OFFSET + 4)
  333.  
  334. /*
  335.  * Maximum number of processors configurable.
  336.  */
  337.  
  338. #define    MACH_MAX_NUM_PROCESSORS        1
  339.  
  340. /*
  341.  * More window-related constants
  342.  */
  343. #define    MACH_NUM_WINDOWS        7    /* # of implemented windows */
  344. #define    MACH_VALID_WIM_BITS    0x0000007f    /* is wim value in range? */
  345.  
  346. /*
  347.  * The size of the floating point state size in Mach_RegState.
  348.  */
  349. #define    MACH_FP_STATE_SIZE (8 + (MACH_NUM_FPS*4) + (MACH_FPU_MAX_QUEUE_DEPTH*8))
  350. /*
  351.  * The size of a single saved window (locals and ins) in bytes.
  352.  */
  353. #define    MACH_SAVED_WINDOW_SIZE    (MACH_NUM_LOCALS * 4 + MACH_NUM_INS * 4)
  354.  
  355. /*
  356.  * The size of the state frame that's saved on interrupts, etc.  This must
  357.  * be the size of Mach_RegState, and this is checked in machCode.c.  We
  358.  * shouldn't succeed in booting if these constants are out of whack.  Keep
  359.  * it this way!  Size is in bytes.
  360.  */
  361. #define    MACH_SAVED_STATE_FRAME    (MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE +\
  362.                 MACH_NUM_EXTRA_ARGS * 4 + MACH_NUM_GLOBALS * 4\
  363.                 + MACH_FP_STATE_SIZE)
  364.  
  365. /*
  366.  * The compiler stores parameters to C routines in its caller's stack frame,
  367.  * so this is at %fp + some_amount.  "Some_amount has to be below (higher addr)
  368.  * than the saved window area, so this means all routines that call C routines
  369.  * with arguments must have a stack frame that is at least
  370.  * MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE = 96 bytes.  If the
  371.  * frame is also being used for trap state, then it's
  372.  * MACH_SAVED_STATE_FRAME + MACH_INPUT_STORAGE.  This MACH_INPUT_STORAGE is
  373.  * the space for calleeInputs in the Mach_Reg_State structure.
  374.  */
  375. #define    MACH_INPUT_STORAGE    (MACH_NUM_INS * 4)
  376.  
  377. /*
  378.  * Ugh, there are only 6 input register storage slots, and one "hidden param"
  379.  * slot for an agregate return value.  This is the space before the area
  380.  * where parameters past the 6th begin.
  381.  */
  382. #define    MACH_ACTUAL_HIDDEN_AND_INPUT_STORAGE    (7 * 4)
  383. /*
  384.  * Number of input registers really used as parameters.
  385.  */
  386. #define    MACH_NUM_REAL_IN_REGS    6
  387.  
  388. /*
  389.  * This doesn't include the space for extra params, since we never use
  390.  * it where extra params are needed.
  391.  */
  392. #define    MACH_FULL_STACK_FRAME    (MACH_SAVED_WINDOW_SIZE + MACH_INPUT_STORAGE)
  393.  
  394.  
  395. /*
  396.  * Constant for offset of first argument in a saved window area.
  397.  */
  398. #define    MACH_ARG0_OFFSET    (MACH_NUM_LOCALS * 4)
  399.  
  400. /*
  401.  * Constant for offset of fp in saved window area.  Fp is %i6.
  402.  */
  403. #define    MACH_FP_OFFSET        (MACH_NUM_LOCALS * 4 + 6 * 4)
  404. #define    MACH_FP_REG        6
  405.  
  406. /*
  407.  * Constant for offset of return pc in saved window area.  RetPC is %i7.
  408.  */
  409. #define    MACH_RETPC_OFFSET    (MACH_NUM_LOCALS * 4 + 7 * 4)
  410.  
  411. /*
  412.  * Constant for offset of return from trap pc reg in saved window area.
  413.  * RetFromTrap pc is %l1.
  414.  */
  415. #define    MACH_TRAP_PC_OFFSET    (4)
  416.  
  417. /*
  418.  * Constant for offset of saved psr in trap regs in saved window area.
  419.  * CurPsr is %l0.
  420.  */
  421. #define    MACH_PSR_OFFSET        (0)
  422.  
  423. /*
  424.  * Number of parameters beyond the sixth that are allowed on trap entry (for
  425.  * system calls.
  426.  */
  427. #define    MACH_NUM_EXTRA_ARGS    (SYS_MAX_ARGS - 6)
  428.  
  429. /*
  430.  * The number of registers.
  431.  * MACH_NUM_GLOBALS - Number of %g registers in sparc.
  432.  * MACH_NUM_INS     - Number of %i registers in sparc.
  433.  * MACH_NUM_LOCALS  - Number of %l registers in sparc.
  434.  * MACH_NUM_WINDOW_REGS - Number of registers in each window.
  435.  * MACH_NUM_FPS     - Number of %f registers in sparc. This registers may be
  436.  *              used as MACH_NUM_FPS floats or MACH_NUM_FPS/2 doubles or
  437.  *              MACH_NUM_FPS/4 extendeds.
  438.  * MACH_FPU_MAX_QUEUE_DEPTH - The maximum number of entires in the FPU queue
  439.  *                  of unfinished instructions.  This number is 
  440.  *                  implementation dependent with the current 
  441.  *                  value set to match SunOS 4.0.3.
  442.  * 
  443.  */
  444. #define    MACH_NUM_GLOBALS        8
  445. #define    MACH_NUM_INS            8
  446. #define    MACH_NUM_LOCALS            8
  447. #define    MACH_NUM_WINDOW_REGS        (MACH_NUM_LOCALS + MACH_NUM_INS)
  448. #define    MACH_NUM_FPS            32
  449. #define    MACH_FPU_MAX_QUEUE_DEPTH    16
  450. /*
  451.  * The amount to shift left by to multiply a number by the number of registers
  452.  * per window.  How would I get this from the constant above?
  453.  */
  454. #define    MACH_NUM_REG_SHIFT        4
  455.  
  456. /*
  457.  * Definitions of registers.
  458.  *
  459.  *
  460.  * The different types of registers.
  461.  *
  462.  *    r0 to r7    globals        g0 to g7
  463.  *    r8 to r15    outs        o0 to o7
  464.  *    r16 to r23    locals        l0 to l7
  465.  *    r24 to r31    ins        i0 to i7
  466.  *    f0 to f31    floating points
  467.  *
  468.  *        Special Registers:
  469.  *    current sp        = o6 = r14
  470.  *    current fp        = i6 = r30 = caller's sp
  471.  *    "0 & discard reg"    = g0 = r0
  472.  *    ret addr from C call    = o7 = r15 in old window
  473.  *    ret value from C call    = o0 = r8 in old window
  474.  *    ret addr to C call    = i7 = r31 in new window
  475.  *    ret val to C call    = i0 = r24 in new window
  476.  *    psr saved into        = l0 = r16 as first part of trap
  477.  *    ret pc from trap    = l1 = r17 in new window
  478.  *    ret npc from trap    = l2 = r18 in new window
  479.  *    tbr from trap        = l3 = r19 as first part of trap
  480.  *    y from trap        = l4 = r20 as first part of trap
  481.  *
  482.  * System routines may end up using a window pointed to by wim if a trap
  483.  * was taken before we got a window overflow.  In this case, they can use
  484.  * the local registers, but not the in or out registers, since they may be
  485.  * in use.  They can use global registers known to be free.
  486.  *
  487.  * NOTE: the order of the what's stored into the local routines is important
  488.  * since that's what gets saved on a stack frame for interrupts, etc.  If this
  489.  * changes, the corresponding changes need to be made in machAsmDefs.h and
  490.  * the mach.h definition of Mach_RegState.
  491.  *
  492.  *    RETURN_ADDR_REG    (r15)    Where the return address from a function call
  493.  *                is stored at call-time.
  494.  *    RETURN_ADDR_REG_CHILD (r31)
  495.  *                Where the called window finds return addr.
  496.  *    CUR_PSR_REG    (r16)    Register where psr is stored at trap time.
  497.  *    CUR_PC_REG    (r17)    Register where the first PC is stored on a trap.
  498.  *    NEXT_PC_REG    (r18)    Register where the 2nd PC is stored on a trap.
  499.  *    CUR_TBR_REG    (r19)    Register where the tbr is stored on a trap.
  500.  *    CUR_Y_REG    (r20)    Register where the y reg is stored on a trap.
  501.  *    SAFE_TEMP    (r21)     Register that cannot be modified by macros or
  502.  *                subroutines within the same window.
  503.  *    VOL_TEMP[1-2]    (r22-r23)
  504.  *                Volatile temporary registers.  Means that
  505.  *                macros in machAsmDefs.h can modify these
  506.  *                registers.
  507.  *    RETURN_VAL_REG    (r8)    Where a value is returned from a C routine.
  508.  *    RETURN_VAL_REG_CHILD (r24)
  509.  *                Where to return a value to our caller.
  510.  *
  511.  */
  512. #define    RETURN_ADDR_REG        r15        /* o7 */
  513. #define    RETURN_ADDR_REG_CHILD    r31        /* i7 */
  514. #define    CUR_PSR_REG        r16        /* l0 */
  515. #define    CUR_PC_REG        r17        /* l1 */
  516. #define    NEXT_PC_REG        r18        /* l2 */
  517. #define    CUR_TBR_REG        r19        /* l3 */
  518. #define    CUR_Y_REG        r20        /* l4 */
  519. #define    SAFE_TEMP        r21        /* l5 */
  520. #define    VOL_TEMP1        r22        /* l6 */
  521. #define    VOL_TEMP2        r23        /* l7 */
  522. #define    RETURN_VAL_REG        r8        /* o0 */
  523. #define    RETURN_VAL_REG_CHILD    r24        /* i0 */
  524. #define    OUT_TEMP1        r12        /* o4 */
  525. #define    OUT_TEMP2        r13        /* o5 */
  526.  
  527.  
  528. #endif /* _MACHCONST */
  529.